package com.tang.lts.core.jvmmonitor.mbean;

import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;

/**
 * @author Tang
 * @classname JVMGC
 * @description [  ]
 * @date 2022/5/10 13:56
 */
public class JVMGC implements JVMGCMBean {

    private final static JVMGC instance = new JVMGC();

    public static JVMGC getInstance() {
        return instance;
    }

    private GarbageCollectorMXBean fullGC;
    private GarbageCollectorMXBean youngGC;

    public JVMGC() {
        for (GarbageCollectorMXBean item : ManagementFactory.getGarbageCollectorMXBeans()) {
            if ("ConcurrentMarkSweep".equals(item.getName()) //
                    || "MarkSweepCompact".equals(item.getName()) //
                    || "PS MarkSweep".equals(item.getName()) //
                    || "G1 Old Generation".equals(item.getName()) //
                    || "Garbage collection optimized for short pausetimes Old Collector".equals(item.getName()) //
                    || "Garbage collection optimized for throughput Old Collector".equals(item.getName()) //
                    || "Garbage collection optimized for deterministic pausetimes Old Collector".equals(item.getName()) //
            ) {
                fullGC = item;
            } else if ("ParNew".equals(item.getName()) //
                    || "Copy".equals(item.getName()) //
                    || "PS Scavenge".equals(item.getName()) //
                    || "G1 Young Generation".equals(item.getName()) //
                    || "Garbage collection optimized for short pausetimes Young Collector".equals(item.getName()) //
                    || "Garbage collection optimized for throughput Young Collector".equals(item.getName()) //
                    || "Garbage collection optimized for deterministic pausetimes Young Collector".equals(item.getName()) //
            ) {
                youngGC = item;
            }
        }
    }

    @Override
    public long getYoungGCCollectionCount() {
        return 0;
    }

    @Override
    public long getYoungGCCollectionTime() {
        return 0;
    }

    @Override
    public long getFullGCCollectionCount() {
        return 0;
    }

    @Override
    public long getFullGCCollectionTime() {
        return 0;
    }

    @Override
    public long getSpanYoungGCCollectionCount() {
        return 0;
    }

    @Override
    public long getSpanYoungGCCollectionTime() {
        return 0;
    }

    @Override
    public long getSpanFullGCCollectionCount() {
        return 0;
    }

    @Override
    public long getSpanFullGCCollectionTime() {
        return 0;
    }
}